using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Cartoon
{
    static class Global
    {
        public static int LeftSize = 275;
        public static int RightSize = 400;
        public static string NewCartoonUrl = "http://dx.78land.com/mh/newcomic.htm";
        public static string NewComicUrl = "http://dx.78land.com/mh/new.htm";        

        public static string[] ServerUrls = { "dx.78land.com", "wt.78land.com", "dx2.78land.com" };        

        public static string[] GetServerResource(string url)
        {
            url = url.ToLower();
            string[] servers = new string[ServerUrls.Length];
            int index = -1;

            for (int i = 0; i < ServerUrls.Length; ++i)
            {
                if (!url.Contains(ServerUrls[i]))
                    continue;

                index = i;
            }

            if (index == -1)
                throw new Exception(string.Format("not support this url {0}", url));

            for(int i = 0; i < ServerUrls.Length; ++i)
                servers[i] = url.Replace(ServerUrls[index], ServerUrls[i]);
            return servers;
        }

        public static void OnMessage(ToolTipIcon icon, string message)
        {
            MessageEventArgs args = new MessageEventArgs();
            args.Icon = icon;
            args.Message = message;
            Base.EventHelper.Raise<MessageEventArgs>(Message, null, args);
        }
        public static event EventHandler<MessageEventArgs> Message = null;
    }

    public class MessageEventArgs : EventArgs
    {
        public ToolTipIcon Icon;
        public string Message;
    }
}
